
package com.funo.government.info.utils;

import com.funo.government.info.R;
import com.funo.government.info.bean.AreaInfo;
import com.funo.government.info.constant.Constant;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class PreferenceUtils {
    /**
     * 获取本地保存的区域id
     * 
     * @param context
     * @return
     */
    public static String getLocalAreaId(Context context) {
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        return preferences.getString(Constant.PRE_KEY_AREA_ID,
                context.getString(R.string.default_area_id));
    }

    /**
     * 保存区域信息
     * 
     * @param context
     * @param areaInfo
     */
    public static void saveAreaId(Context context, AreaInfo areaInfo) {
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        preferences.edit().putString(Constant.PRE_KEY_AREA_ID, areaInfo.areaId)
                .putString(Constant.PRE_KEY_AREA_NAME, areaInfo.areaName).commit();
    }
    
}
